//
//  ShipperSource_TableViewCell.m
//  CarNetwork_logistics
//
//  Created by 高启 on 15/11/10.
//  Copyright © 2015年 turingEdu. All rights reserved.
//

#import "ShipperSource_TableViewCell.h"
#import "Helpers.h"
#import "Masonry.h"
#import "CWStarRateView.h"

@implementation ShipperSource_TableViewCell
{
    CWStarRateView      *ratingControl;
    UIView              *boardView;
    UIView              *headerView;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setSelectionStyle:UITableViewCellSelectionStyleNone];
        [self createCellView];
    }
    
    return self;
}

- (void)createCellView{
   
    headerView = [[UIView alloc]init];
    [headerView setBackgroundColor:[UIColor HexStrWithColor:@"f3f6f5"]];
    [self addSubview:headerView];
    
    self.customer_designationLabel = [[UILabel alloc]init];
    [self addSubview:self.customer_designationLabel];
    [self.customer_designationLabel setText:@"客户指定 : "];
    [self.customer_designationLabel setTextColor:[UIColor HexStrWithColor:@"ca3706"]];
    [self.customer_designationLabel setFont:[UIFont systemFontOfSize:16]];
    //[self.customer_designationLabel setFrame:CGRectMake(9, 15, kUIScreenWidth*0.225, 16)];
    
    self.customer_designationContentLabel = [[UILabel alloc]init];
    [self addSubview:self.customer_designationContentLabel];
    [self.customer_designationContentLabel setTag:102];
    [self.customer_designationContentLabel setText:@"123112312"];
    [self.customer_designationContentLabel setTextColor:[UIColor HexStrWithColor:@"ca3706"]];
    [self.customer_designationContentLabel setFont:[UIFont systemFontOfSize:16]];

    //发布方
    self.pulicLabel = [[UILabel alloc]init];
    [self addSubview:self.pulicLabel];
    [self.pulicLabel setText:@"发布方 : "];
    [self.pulicLabel setTextColor:[UIColor HexStrWithColor:@"6e6e6e"]];
    [self.pulicLabel setFont:[UIFont systemFontOfSize:16]];

    self.pulicContentLabel = [[UILabel alloc]init];
    [self addSubview:self.pulicContentLabel];
    [self.pulicContentLabel setText:@"123112312"];
    [self.pulicContentLabel setTag:202];
    [self.pulicContentLabel setTextColor:[UIColor HexStrWithColor:@"ca3706"]];
    [self.pulicContentLabel setFont:[UIFont systemFontOfSize:16]];
    
    //认证

    self.authenticationImageView = [[UIImageView alloc]init];
    [self addSubview:self.authenticationImageView];
    [self.authenticationImageView setContentMode:UIViewContentModeScaleToFill];
    [self.authenticationImageView setTag:203];
    
    // 智能匹配
    self.matchingImageView = [[UIImageView alloc]init];
    [self addSubview:self.matchingImageView];
    [self.matchingImageView setContentMode:UIViewContentModeScaleToFill];
    [self.matchingImageView setTag:204];

    
    self.evaluateLabel = [[UILabel alloc]init];
    [self addSubview:self.evaluateLabel];
    [self.evaluateLabel setText:@"服务评价 : "];
    [self.evaluateLabel setTextColor:[UIColor HexStrWithColor:@"6e6e6e"]];
    [self.evaluateLabel setFont:[UIFont systemFontOfSize:16]];
    
    ratingControl = [[CWStarRateView alloc]initWithFrame:CGRectMake(0, 0, 150, 20)];
    [self.contentView addSubview:ratingControl];
    ratingControl.scorePercent = 2;
    ratingControl.hasAnimation = YES;

    //路线

    self.routeLabel = [[UILabel alloc]init];
    [self addSubview:self.routeLabel];
    [self.routeLabel setText:@"路线 : "];
    [self.routeLabel setTextColor:[UIColor HexStrWithColor:@"6e6e6e"]];
    [self.routeLabel setFont:[UIFont systemFontOfSize:16]];
   
    //品类
    
    self.categoryLabel = [[UILabel alloc]init];
    [self addSubview:self.categoryLabel];
    [self.categoryLabel setText:@"品类 : "];
    [self.categoryLabel setTextColor:[UIColor HexStrWithColor:@"6e6e6e"]];
    [self.categoryLabel setFont:[UIFont systemFontOfSize:16]];

    //路线
    
    self.weightLabel = [[UILabel alloc]init];
    [self addSubview:self.weightLabel];
    [self.weightLabel setText:@"重量 : "];
    [self.weightLabel setTextColor:[UIColor HexStrWithColor:@"6e6e6e"]];
    [self.weightLabel setFont:[UIFont systemFontOfSize:16]];
   
    //价格
    
    self.priceLabel = [[UILabel alloc]init];
    [self addSubview:self.priceLabel];
    [self.priceLabel setText:@"价格区间 : "];
    [self.priceLabel setTextColor:[UIColor HexStrWithColor:@"6e6e6e"]];
    [self.priceLabel setFont:[UIFont systemFontOfSize:16]];
    //[self.priceLabel setFrame:CGRectMake(9, 15, kUIScreenWidth*0.224, 15)];
    
    
    //Delivery date
    
    
    self.deliveryDateLabel = [[UILabel alloc]init];
    [self addSubview:self.deliveryDateLabel];
    [self.deliveryDateLabel setText:@"发货日期 : "];
    [self.deliveryDateLabel setTextColor:[UIColor HexStrWithColor:@"6e6e6e"]];
    [self.deliveryDateLabel setFont:[UIFont systemFontOfSize:16]];
    //[deliveryDateLabel setFrame:CGRectMake(9, 15, kUIScreenWidth*0.224, 15)];
    
    
    self.deliveryDateContentLabel = [[UILabel alloc]init];
    [self addSubview:self.deliveryDateContentLabel];
    [self.deliveryDateContentLabel setText:@"2015-11-11"];
    self.deliveryDateContentLabel.backgroundColor = [UIColor greenColor];
    [self.deliveryDateContentLabel setTextColor:[UIColor HexStrWithColor:@"6e6e6e"]];
    [self.deliveryDateContentLabel setFont:[UIFont systemFontOfSize:16]];
    
    
    //Delivery date
    
    
    self.publicDateLabel = [[UILabel alloc]init];
    [self addSubview:self.publicDateLabel];
    [self.publicDateLabel setText:@"发布日期 : "];
    [self.publicDateLabel setTextColor:[UIColor HexStrWithColor:@"6e6e6e"]];
    [self.publicDateLabel setFont:[UIFont systemFontOfSize:16]];
    //[publicDateLabel setFrame:CGRectMake(9, 15, kUIScreenWidth*0.224, 15)];
    
    
    self.publicDateContentLabel = [[UILabel alloc]init];
    [self addSubview:self.publicDateContentLabel];
    [self.publicDateContentLabel setText:@"2015-11-11"];
    self.publicDateContentLabel.backgroundColor = [UIColor redColor];
    [self.publicDateContentLabel setTextColor:[UIColor HexStrWithColor:@"6e6e6e"]];
    [self.publicDateContentLabel setFont:[UIFont systemFontOfSize:16]];
    
    
    //remarks
    self.remarksLabel = [[UILabel alloc]init];
    [self addSubview:self.remarksLabel];
    [self.remarksLabel setText:@"备注 : "];
    [self.remarksLabel setTextColor:[UIColor HexStrWithColor:@"6e6e6e"]];
    [self.remarksLabel setFont:[UIFont systemFontOfSize:16]];
    //[self.remarksLabel setFrame:CGRectMake(9, 15, kUIScreenWidth*0.224, 15)];
    
    
    self.remarksContentLabel = [[UILabel alloc]init];
    [self addSubview:self.remarksContentLabel];
    [self.remarksContentLabel setText:@"备注 asdafdsfdfasdf : "];
    [self.remarksContentLabel setTextColor:[UIColor HexStrWithColor:@"6e6e6e"]];
    [self.remarksContentLabel setFont:[UIFont systemFontOfSize:16]];
    
    //分割线
    
    boardView = [[UIView alloc]init];
    [boardView setBackgroundColor:[UIColor HexStrWithColor:@"aaaaaa"]];
    [self addSubview:boardView];

    self.grapBtn = [UIButtonHepler buttonWithType:UIButtonTypeCustom];
    [self.grapBtn setTitle:@"立即抢单" forState:UIControlStateNormal];
    [self.grapBtn setBackgroundColor:[UIColor HexStrWithColor:@"d13800"]];
    [self.grapBtn.layer setMasksToBounds:YES];
    [self.grapBtn.layer setCornerRadius:4];
    [self addSubview:self.grapBtn];
    
    self.telBtn = [UIButtonHepler buttonWithType:UIButtonTypeCustom];
    [self.telBtn setTitle:@"拨打电话" forState:UIControlStateNormal];
    [self.telBtn setBackgroundColor:[UIColor HexStrWithColor:@"aaaaaa"]];
    [self.telBtn.layer setMasksToBounds:YES];
    [self.telBtn.layer setCornerRadius:4];
    [self addSubview:self.telBtn];
    
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [headerView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.top.equalTo(self);
        make.centerX.equalTo(self);
        make.size.mas_equalTo(CGSizeMake(kUIScreenWidth, 9));
        
    }];
    //用户指定
    [self.customer_designationLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(headerView.mas_bottom).with.offset(15);
         make.left.equalTo(self.mas_left).with.offset(9);
         make.width.mas_equalTo(self.mas_width).with.multipliedBy(0.229);
         make.height.mas_equalTo(@16);
         
     }];
    
    [self.customer_designationContentLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(self.customer_designationLabel);
         make.left.equalTo(self.customer_designationLabel.mas_right).with.offset(9);
         make.height.mas_equalTo(@16);
         make.width.mas_equalTo(kUIScreenWidth).with.multipliedBy(0.5);
         
     }];
    //用户发布
    [self.pulicLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.mas_left).with.offset(24);
         make.top.equalTo(self.customer_designationLabel.mas_bottom).with.offset(16+15);
         make.size.equalTo(self.customer_designationLabel);
         
     }];
    
    
    [self.pulicContentLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(self.pulicLabel);
         make.left.equalTo(self.pulicLabel.mas_right).with.offset(9);
         make.height.mas_equalTo(@16);
         make.width.mas_equalTo(kUIScreenWidth / 2 - 50).with.multipliedBy(0.5);
         
     }];
    //认证图片
    UIImage *authenticationImage = [UIImage imageNamed:@"yrz"];
    [self.authenticationImageView setImage:authenticationImage];
    [self.authenticationImageView mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(self.pulicContentLabel);
         make.left.equalTo(self.pulicContentLabel.mas_right);
         make.size.mas_equalTo(authenticationImage.size);
         
     }];
    
    // 智能匹配
    
    [self.matchingImageView mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(headerView.mas_bottom).with.offset(0);
         make.left.equalTo(self.pulicContentLabel.mas_right).offset(70);
         make.size.mas_equalTo(authenticationImage.size);
         make.height.mas_equalTo(@58);
         make.width.mas_equalTo(@65);
         
     }];

    
    //服务评价
   [self.evaluateLabel mas_makeConstraints:^(MASConstraintMaker *make)
   {
       make.top.equalTo(self.pulicLabel.mas_bottom).with.offset(16+15);
       make.left.equalTo(self.customer_designationLabel);
       make.size.equalTo(self.pulicLabel);

    }];

    //星星
    ratingControl.frame = CGRectMake(self.evaluateLabel.frame.size.width + self.evaluateLabel.frame.origin.x,self.pulicLabel.frame.origin.y+self.pulicLabel.frame.size.height+28, 150, 20);

    //路线
    [self.routeLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.pulicLabel).with.offset(20);
         make.top.equalTo(self.evaluateLabel.mas_bottom).with.offset(15+16);
         make.height.mas_equalTo(@16);
         make.width.mas_equalTo(kUIScreenWidth).with.multipliedBy(0.224);
         
     }];

    //品类
    [self.categoryLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.pulicLabel).with.offset(20);
         make.top.equalTo(self.routeLabel.mas_bottom).with.offset(15+16);
         make.height.mas_equalTo(@16);
         make.width.mas_equalTo(kUIScreenWidth).with.multipliedBy(0.224);
         
     }];

    [self.weightLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.pulicLabel).with.offset(20);
         make.top.equalTo(self.categoryLabel.mas_bottom).with.offset(15+16);
         make.height.mas_equalTo(@16);
         make.width.mas_equalTo(kUIScreenWidth).with.multipliedBy(0.224);
         
     }];
    //价格
    
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.mas_left).with.offset(9);
         make.top.equalTo(self.weightLabel.mas_bottom).with.offset(15+16);
         make.height.mas_equalTo(@16);
         make.width.mas_equalTo(kUIScreenWidth).with.multipliedBy(0.224);
         
     }];
    //发货日期
    [self.deliveryDateLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.mas_left).with.offset(9);
         make.top.equalTo(self.priceLabel.mas_bottom).with.offset(15+16);
         make.height.mas_equalTo(@16);
         make.width.mas_equalTo(kUIScreenWidth).with.multipliedBy(0.224);
         
     }];
    
    [self.deliveryDateContentLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.deliveryDateLabel.mas_right).with.offset(9);
         make.top.equalTo(self.deliveryDateLabel.mas_bottom).with.offset(15+16);
         make.height.mas_equalTo(@16);
         make.width.mas_equalTo(kUIScreenWidth).with.multipliedBy(0.5);
         
     }];
    
    [self.publicDateLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.mas_left).with.offset(9);
         make.top.equalTo(self.deliveryDateLabel.mas_bottom).with.offset(15+16);
         make.height.mas_equalTo(@16);
         make.width.mas_equalTo(kUIScreenWidth).with.multipliedBy(0.224);
         
     }];
    
    [self.publicDateContentLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.publicDateLabel.mas_right).with.offset(9);
         make.top.equalTo(self.publicDateLabel);
         make.height.mas_equalTo(@16);
         make.width.mas_equalTo(kUIScreenWidth).with.multipliedBy(0.5);
         
     }];
    
    [self.remarksLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.pulicLabel).with.offset(20);
         make.top.equalTo(self.publicDateLabel.mas_bottom).with.offset(15+16);
         make.height.mas_equalTo(@16);
         make.width.mas_equalTo(kUIScreenWidth).with.multipliedBy(0.224);
         
     }];
    
    [self.remarksContentLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.remarksLabel.mas_right).with.offset(9);
         make.top.equalTo(self.remarksLabel);
         make.height.mas_equalTo(@16);
         make.width.mas_equalTo(kUIScreenWidth).with.multipliedBy(0.5);
         
     }];
    
    [boardView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.top.equalTo(self.remarksLabel.mas_bottom).with.offset(24);
        make.left.equalTo(self.mas_left).with.offset(8);
        make.right.equalTo(self.mas_right).with.offset(-8);
        make.height.mas_equalTo(@1);
        
    }];
    
    [self.grapBtn mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.top.equalTo(boardView.mas_bottom).with.offset(11);
        make.left.equalTo(self.mas_left).with.offset(16);
        make.size.mas_equalTo(CGSizeMake(kUIScreenWidth*0.44,44));
        
    }];
    
    [self.telBtn mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(boardView.mas_bottom).with.offset(11);
         make.left.equalTo(self.grapBtn.mas_right).with.offset(12);
         make.size.equalTo(self.grapBtn);
         
     }];

}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
